package com.zhouzh3.excel2sql;

import java.util.List;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;

import com.zhouzh3.excel2sql.model.Column;
import com.zhouzh3.excel2sql.model.Table;
import com.zhouzh3.excel2sql.service.MetadataService;
import com.zhouzh3.excel2sql.util.SqlSessionFactoryUtil;

public class XlsxGenRun {
	protected static Logger logger = Logger.getLogger(XlsxGenRun.class);

	public static void main(String[] args) {
		SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtil.getSqlSessionFactory();
		MetadataService service = new MetadataService(sqlSessionFactory);

		List<String> list = service.querySchemas();
		for (String schema : list) {
			logger.debug(schema);
			List<Table> tables = service.queryTables(schema);
			for (Table table : tables) {
				logger.debug(table);
				List<Column> columns = service.queryColumns(schema, table.getCode());
				table.addColumns(columns);
			}
			logger.debug("/r/n");
		}
	}
}
